import xlwt
import os

"""
文件目录结构写到xls文件

"""
_row = 1;  # 横向
path = "E:\\Project\\KuaiMa\\111\\福播0408_jpg"

def loop(sheet, path, deep):
    print(path,deep)
    global _row
    for c1 in os.listdir(path):
        _c1Path = os.path.join(path, c1)
        _row += 1;
        sheet.write(_row, deep, c1)
        if (os.path.isdir(_c1Path)):
            _c1Deep = deep + 1;
            loop(sheet, _c1Path, _c1Deep)


def doXls():
    wbk = xlwt.Workbook()
    sheet = wbk.add_sheet('Sheet1', cell_overwrite_ok=True)
    loop(sheet, path, 1)

    wbk.save('aa.xls')


if __name__ == '__main__':
    doXls()
